﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.world {
    import flash.events.*;
    import flash.display.*;
    import flash.geom.*;
    import flash.filters.*;
    import flash.utils.*;
    import net.wooga.pets.views.components.*;
    import net.wooga.pets.utils.*;

    public class AbstractActorView extends AbstractView {

        protected var _animationState:String;
        private var _highlightTimer:Timer;
        private var _speechBubbleContainer:Sprite;

        public function AbstractActorView(_arg1:String, _arg2:Number, _arg3:Number, _arg4:String){
            super(_arg1, _arg2, _arg3, _arg4);
            setEnabled();
        }
        public function get content():MovieClip{
            return (_asset);
        }
        public function highlightEffect():void{
            this._highlightTimer = new Timer(300, 6);
            this._highlightTimer.addEventListener(TimerEvent.TIMER, this.onHighlightTick);
            this._highlightTimer.addEventListener(TimerEvent.TIMER_COMPLETE, this.onHighlightComplete);
            this._highlightTimer.start();
        }
        public function set speechBubblePosition(_arg1:Point):void{
            if (!this._speechBubbleContainer){
                this.addSpeechBubbleContainer();
            };
            this._speechBubbleContainer.x = ((_arg1.x) || (0));
            this._speechBubbleContainer.y = ((_arg1.y) || (0));
        }
        public function get speechBubblePosition():Point{
            var _local1:Point;
            if (this._speechBubbleContainer){
                _local1 = new Point(this._speechBubbleContainer.x, this._speechBubbleContainer.y);
            };
            return (_local1);
        }
        public function addSpeechBubble(_arg1:MovieClip):void{
            if (!this._speechBubbleContainer){
                this.addSpeechBubbleContainer();
            };
            this.removeSpeechBubble();
            this._speechBubbleContainer.addChild(_arg1);
        }
        public function removeSpeechBubble():void{
            Displays.removeAllChildren(this._speechBubbleContainer);
        }
        public function set direction(_arg1:int):void{
            if (_asset){
                _asset.scaleX = _arg1;
            };
        }
        public function mouseOverEffect(_arg1:MouseEvent=null):void{
            _display.filters = [this.getBitmapFilter()];
        }
        public function mouseOutEffect(_arg1:MouseEvent=null):void{
            _display.filters = Filters.NO_FILTERS;
        }
        protected function onHighlightTick(_arg1:TimerEvent):void{
            if (_display.filters.length){
                this.mouseOutEffect();
            } else {
                this.mouseOverEffect();
            };
        }
        protected function onHighlightComplete(_arg1:TimerEvent):void{
            _display.filters = Filters.NO_FILTERS;
            this._highlightTimer.stop();
            this._highlightTimer.removeEventListener(TimerEvent.TIMER, this.onHighlightTick);
            this._highlightTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, this.onHighlightComplete);
        }
        protected function addSpeechBubbleContainer():void{
            this._speechBubbleContainer = new Sprite();
            this._speechBubbleContainer.mouseChildren = (this._speechBubbleContainer.mouseEnabled = false);
            _display.addChild(this._speechBubbleContainer);
        }
        public function getBitmapFilter():BitmapFilter{
            return (Filters.getFilter(Filters.ACTOR_GLOW));
        }
        public function setAnimationState(_arg1:String, _arg2:Boolean=false):void{
            this.renderAnimationState(_asset, _arg1, _arg2);
        }
        protected function renderAnimationState(_arg1:MovieClip, _arg2:String, _arg3:Boolean=false):void{
            var clipToUpdate = _arg1;
            var animationState = _arg2;
            var force = _arg3;
            animationState = ((animationState) || (this._animationState));
            if (((clipToUpdate) && (((force) || (!((animationState == this._animationState))))))){
                this._animationState = animationState;
                if (clipToUpdate.animation){
                    clipToUpdate.animation.gotoAndStop(this._animationState);
                } else {
                    clipToUpdate.addEventListener(Event.FRAME_CONSTRUCTED, function (_arg1:Event):void{
                        clipToUpdate.removeEventListener(Event.FRAME_CONSTRUCTED, arguments.callee);
                        if (clipHasInstanceName_animation(clipToUpdate)){
                            clipToUpdate.animation.gotoAndStop(_animationState);
                        };
                    });
                };
            };
        }
        public function get speechBubbleContainer():Sprite{
            return (this._speechBubbleContainer);
        }

    }
}//package net.wooga.pets.views.world 
